//-----------------------------------------------------------------------------
//----- WindStartPtPg.cpp : implementation file
#include "StdAfx.h"
#include "StdArx.h"
#include "resource.h"
#include "WindStartPtPg.h"
#include "geassign.h"

//-----------------------------------------------------------------------------
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC (CWindStartPtPg, CAcUiTabChildDialog)

BEGIN_MESSAGE_MAP(CWindStartPtPg, CAcUiTabChildDialog)
	//{{AFX_MSG_MAP(CWindStartPtPg)
	ON_BN_CLICKED(IDC_BTN_PICKPT, OnBtnPickPt)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

//-----------------------------------------------------------------------------
CWindStartPtPg::CWindStartPtPg (CWnd* pParent /*=NULL*/, HINSTANCE hInstance /*=NULL*/) : CAcUiTabChildDialog (pParent, hInstance) {
	//{{AFX_DATA_INIT(CWindStartPtPg)
	m_dXVal = windInfo.m_dXVal;
	m_dYVal = windInfo.m_dYVal;
	//}}AFX_DATA_INIT
}

void CWindStartPtPg::DoDataExchange (CDataExchange *pDX) {
	CAcUiTabChildDialog::DoDataExchange (pDX) ;
	//{{AFX_DATA_MAP(CWindStartPtPg)
	DDX_Text(pDX, IDC_EDIT_XVAL, m_dXVal);
	DDX_Text(pDX, IDC_EDIT_YVAL, m_dYVal);
	//}}AFX_DATA_MAP
}

//-----------------------------------------------------------------------------
void CWindStartPtPg::OnTabActivation (BOOL bActivate) {
	//----- TODO: Add your code here
}

BOOL CWindStartPtPg::OnTabChanging () {
	//----- TODO: Add your code here

	return (TRUE) ;
}

//-----------------------------------------------------------------------------

void CWindStartPtPg::OnBtnPickPt() 
{
	// TODO: Add your control notification handler code here
	// Here we hide our modal dialog property sheet
	// to allow the user to pick a point
	AcGePoint3d pkPt;
	int retCode;

	GetParent()->GetParent()->EnableWindow(TRUE);
	// Enable the parent window
	// which in our case is the
	// AutoCAD main window.

	GetParent()->ShowWindow(SW_HIDE);		// Hide our dialog
	GetParent()->GetParent()->SetFocus();	// Give AutoCAD the focus.

	acedInitGet(NULL, NULL);

	retCode = acedGetPoint(NULL, "\nPick lower left corner of window: ",
							asDblArray(pkPt));

	switch(retCode)
	{
		case RTCAN  :
		case RTNONE :

			pkPt.set(0.0, 0.0, 0.0);

		break;

		case RTNORM :



		break;
	}

	m_dXVal = pkPt.x;
	m_dYVal = pkPt.y;

	GetParent()->ShowWindow(SW_SHOW); // Display our dialog again
	GetParent()->SetFocus(); // Reset the focus back to ourselves
	GetParent()->GetParent()->EnableWindow(FALSE); // Disable AutoCAD window
	GetParent()->EnableWindow(TRUE); // Enable our dialog

	// Transfer the data values from the member variables
	// to the dialog.
	UpdateData(FALSE);

	
}
